/**
 * $Id: UserAdminController.java 19 2011-06-11 04:06:06Z feigme $
 */
package com.iary.interfaces.web.admin.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.iary.application.UserServiceFacade;
import com.iary.domain.model.user.User;
import com.iary.infrastructure.orm.Page;

@Controller
@RequestMapping("/admin/user")
public class UserAdminController {

	@Autowired
	private UserServiceFacade userServiceFacade;

	@RequestMapping(value = "/list.do")
	public String execute() {
		return "user/user-list";
	}

	@RequestMapping(value = "/search.do")
	public ModelAndView search(UserAdminCommand command) {
		Page<User> page = new Page<User>(5);
		page.setPageNo(command.getPageNo());
		page.setOrderBy("id");
		page.setOrder("desc");
		page = userServiceFacade.findAll(page);
		return new ModelAndView("user/user-list", "page", page);
	}

}
